package com.example.love_margin.Mapper;


import com.example.love_margin.Entity.Sale;
import com.example.love_margin.Entity.Science;
import com.example.love_margin.Mapper.configuer.DeleteMany;
import com.example.love_margin.Mapper.configuer.SeletPetPicture;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SaleMapper {


    @Insert("INSERT INTO sale(sale_title,sale_link,sale_picture)values(#{sale_title},#{sale_link},#{sale_picture})")
    int addSale(Sale sale);

    //删除单条
    @Delete("DELETE FROM sale WHERE sale_id=#{sale_id}")
    int deleteSale(int sale_id);

    //批量删除

    @DeleteProvider(type = DeleteMany.class,method = "deleteM")
    int deleteSales(String sql);


    //查询多个对象的图片的地址用以删除
    @SelectProvider(type = SeletPetPicture.class,method = "SelectPetP")
    List<String> selectSaleAll(String URL);


    //通过id进行修改信息
    @Update("UPDATE science SET sale_title=#{sale_title},sale_link=#{sale_link},sale_picture=#{sale_picture} WHERE sale_id = #{sale_id}")
    int upSale(Sale sale);

    //查询单条科普信息
    @Select("SELECT * FROM science WHERE sale_id = #{sale_id}")
    Sale selectOneSale(int sale_id);

    //查询多条科普信息
    @Select("SELECT * FROM sale")
    List<Sale> selectAll();

}
